
#include "object.hpp"
#include "world.hpp"

#include <GL/gl.h>
#include <GL/glut.h>

static int hwin = 0;

calypso::World rootWorld (1.0f);

void frametimer (int value)
{
	glutPostRedisplay ();
	glutTimerFunc (10, frametimer, 0);
}

void display ()
{
	glClear (GL_COLOR_BUFFER_BIT);

	rootWorld.draw ();

	glutSwapBuffers ();
}

void keyboard (unsigned char _key, int _x, int _y)
{
	if (_key == 'q')
	{
		glutDestroyWindow (hwin);
		exit (0);
	}
}

int main (int _argc, char **_argv)
{
	calypso::Teapot teapot (1.0f);
	teapot.translate (-1.0f, 0.0f, -1.0f);

	calypso::Torus torus (1.0f, 0.2f);
	torus.translate (1.5f, 0.0f, -1.0f);

	rootWorld.push (&teapot);
	rootWorld.push (&torus);

	/* start GLUT :*/

	glutInit (&_argc, _argv);
	glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE);
	glutInitWindowSize (500, 500);

	hwin = glutCreateWindow ("calypso");

	glutDisplayFunc (display);
	glutKeyboardFunc (keyboard);

	glClearColor (0.0f, 0.0f, 0.0f, 1.0f);

	frametimer (0);
	glutMainLoop ();

	return -1;
}
